<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        #box {
            width: 500px;
            height: 500px;
            background-color: lightskyblue;
            border: 10px solid black;
        }

        #content {
            width: 200px;
            height: 200px;
            background-color: brown;
            padding: 60px;
            border: 10px solid black;
            position: relative;
            left: 30px;
            top: 30px;
        }
    </style>
</head>
<body>

<div id="box">
    <div id="content"></div>
</div>

<script>
    var content = document.getElementById('content');
    // offset如果父元素中有定位元素
    // 都是相对于上一个定位元素(position不为static)定位.
    // 如果没有地位的元素,是相对于屏幕的
    // offset这种属性,他是只读的,不能改变
    console.log(content.offsetLeft);
    console.log(content.offsetTop);

    content.style.left = '200px'
</script>

</body>
</html>